package com.example.demo.config;

import com.example.demo.tenant.TenantContext;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;

public class TenantIdentifierResolver implements CurrentTenantIdentifierResolver {
    @Override
    public String resolveCurrentTenantIdentifier() {
        Long tenantId = TenantContext.getCurrentTenant();
        if (tenantId != null) {
            return tenantId.toString();
        }
        return "default";
    }

    @Override
    public boolean validateExistingCurrentSessions() {
        return true;
    }
}
